package com.controller.teacher;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date; 
import java.util.Calendar;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.metamodel.SetAttribute;

import com.jfinal.core.ActionKey;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.model.Thesistitle;
import com.model.comobject;

public class DissertationControllerTea extends Controller{
	//默认调用方法
	@ActionKey("/index")
//	public void index() {
//		Integer page = getParaToInt("page");
//		Integer rows = getParaToInt("rows");
//		String sql="from thesistitle as t left join student_rela_thesistitle as srt  ON t.thesistitle_id=srt.stu_rela_thesis_thesis left join student as s  ON srt.stu_rela_thesis_stu = s.student_id where  t.thesistitle_checkstate = 'F' order by t.thesistitle_id desc";
//		Page<Thesistitle> thesistitlePages=Thesistitle.dao.paginate(page,rows, "select t.thesistitle_id,t.thesistitle_name,t.thesistitle_selected,t.thesistitle_checkstate,t.thesistitle_type,t.thesistitle_source,t.thesistitle_select_way,student_id,concat(s.student_no,'(',s.student_name,')') as Sin", sql);
//		//Page<Dissertation> thesistitlePages=Dissertation.dao.paginate(page,rows, "select *", "from thesistitle order by id desc");
//		setSessionAttr("dissertationList",thesistitlePages.getList() ); 
//    	//Db.paginate(1, 10, "select *","from student order by student_id desc");
//		Map<String, Object> m = new HashMap<String, Object>();
//		m.put("total", thesistitlePages.getTotalRow());
//		m.put("rows", thesistitlePages.getList());
//		renderJson(m);
//	}
	public void index() {
		Integer page = getParaToInt("page");
		Integer rows = getParaToInt("rows");
		int teacher_id=getSessionAttr("teacher_id");
		//已审核论文
		//String sql="from thesistitle as t left join student_rela_thesistitle as srt  ON t.thesistitle_id=srt.stu_rela_thesis_thesis left join student as s  ON srt.stu_rela_thesis_stu = s.student_id where t.thesistitle_checkstate = 'D'or t.thesistitle_checkstate = 'C' order by t.thesistitle_id desc";
		//String sql="from tea_stu_the where teacher_id="+teacher_id+" and (thesistitle_checkstate = 'C' or thesistitle_checkstate = 'D')";
		String sql="from t_the	LEFT JOIN thesistitle on t_the.thesistitle_id =thesistitle.thesistitle_id  where t_the.teacher_id="+teacher_id+"";
		Page<Thesistitle> thesistitlePages=Thesistitle.dao.paginate(page,rows, "select t_the.*", sql);
    	setAttr("confirm",thesistitlePages.getList() ); 
    	Map<String, Object> m = new HashMap<String, Object>();
		m.put("total", thesistitlePages.getTotalRow());
		m.put("rows", thesistitlePages.getList());
		renderJson(m);
	}
	
	
	@ActionKey("/midshow")
	public void midshow() {
		Integer page = getParaToInt("page");
		Integer rows = getParaToInt("rows");
		String sql="from thesistitle as t left join student_rela_thesistitle as srt  ON t.thesistitle_id=srt.stu_rela_thesis_thesis left join student as s  ON srt.stu_rela_thesis_stu = s.student_id where  t.thesistitle_checkstate = 'D' order by t.thesistitle_id desc";
		Page<Thesistitle> thesistitlePages=Thesistitle.dao.paginate(page,rows, "select t.thesistitle_id,t.thesistitle_name,t.thesistitle_selected,t.thesistitle_checkstate,t.thesistitle_type,t.thesistitle_source,t.thesistitle_select_way,student_id,concat(s.student_no,'(',s.student_name,')') as Sin", sql);
		//Page<Dissertation> thesistitlePages=Dissertation.dao.paginate(page,rows, "select *", "from thesistitle order by id desc");
		setSessionAttr("dissertationList",thesistitlePages.getList() ); 
    	//Db.paginate(1, 10, "select *","from student order by student_id desc");
		Map<String, Object> m = new HashMap<String, Object>();
		m.put("total", thesistitlePages.getTotalRow());
		m.put("rows", thesistitlePages.getList());
		renderJson(m);
		
	}
	
	
	@ActionKey("/inoo")
	public void inoo(){
		//int id= getParaToInt("id");
		Integer id=getParaToInt("id");
		Integer tid=getParaToInt("tid");
		System.out.println(id);
		System.out.println("this is test");
		//String sql="select thesistitle_name,student_id,student_name,teacher_name,major_name,department_name,teacher_name,zhicheng_name,stu_rela_thesis_id from midshowview where student_id="+id+"";
		String sql="select midshowview.* from midshowview where student_id="+id+"";
		Record r=Db.findFirst(sql);
		System.out.println("r是。。。。"+r);
		setAttr("dp", r);
		render("/pages1/giveView.jsp");
	}
	//教师带的学生列表
	@ActionKey("/TeaStu")
	public void TeaStu(){
				int tea_id=getSessionAttr("teacher_id");
				String sql="select Sin,student_id from TeaStu where teacher_id="+tea_id+" order by student_id desc";
				List<Record> list=Db.find(sql);
				renderJson(list);
	}
	//论文重要时间表
		@ActionKey("/key")
		public void keytime(){
					String od=getPara("order");
					String sort=getPara("sort");
					int tea_id=getSessionAttr("teacher_id");
					int d_p=Db.queryInt("select teacher_department from teacher where teacher_id="+tea_id+"");
					System.out.println("老师id"+tea_id);
					String sql="select * from teacher_3 where teacher_department ="+d_p+" order by "+sort+" "+od+"";
					List<Record> list=Db.find(sql);
					renderJson(list);
		}
	//选题方式
	@ActionKey("/method")
	public void method(){
		List<Object> l=new ArrayList<Object>();
		comobject cb0=new comobject();
		cb0.setValue("A");
		cb0.setText("学生申请");
		
		comobject cb=new comobject();
		cb.setValue("B");
		cb.setText("盲选");
		
		comobject cb1=new comobject();
		cb1.setValue("C");
		cb1.setText("指定学生");
		
		l.add(cb0);
		l.add(cb);
		l.add(cb1);
		renderJson(l);
	}
	//课题类型
	@ActionKey("/dissType")
	public void dissType(){
		List<Object> l=new ArrayList<Object>();
		comobject cb=new comobject();
		cb.setValue("论文");
		cb.setText("论文");
		comobject cb1=new comobject();
		cb1.setValue("设计");
		cb1.setText("设计");
		l.add(cb);
		l.add(cb1);
		renderJson(l);
	}
	//课题来源
	@ActionKey("/thesissource")
	public void thesissource(){
		//String teacher_department=getPara("");
		String sql="select thesissource.* from thesissource";
		List<Record> list=Db.find(sql);
		renderJson(list);
	}
	@ActionKey("/Add")
	public void Add() throws UnsupportedEncodingException{
		String a=getPara("Sin");
		String b=getPara("dissType");
		System.out.println(a+"  "+b);
	}//删除论文题目
	
	@ActionKey("/delete")
	public void delete() {
		int thesistitle_id=getParaToInt("thesistitle_id");//获取需要删除论文的id
		String thesistitle_select_way=getPara("thesistitle_select_way");
		if(thesistitle_select_way.equals("B")){
			Db.deleteById("teacher_rela_thesistitle", "tch_rela_thesis_thesis",thesistitle_id);
			Db.deleteById("thesistitle", "thesistitle_id",thesistitle_id);
			renderJson("{\"success\":true}");
		}
		if(thesistitle_select_way.equals("C")||thesistitle_select_way.equals("A")){
			Db.deleteById("student_rela_thesistitle","stu_rela_thesis_thesis", thesistitle_id);
			Db.deleteById("teacher_rela_thesistitle","tch_rela_thesis_thesis", thesistitle_id);
			Db.deleteById("thesistitle", "thesistitle_id",thesistitle_id);
			renderJson("{\"success\":true}");
		}
	}
//添加论文
	@ActionKey("/add")
	public void add(){
		System.out.println("this is add");
		String stuId=getPara("stu");//获取学生虚拟主键
		String thesistitle_select_way=getPara("thesistitle_select_way");//选题方式
		Date dt =new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式
		String date = dateFormat.format(dt); 
		String tn=getPara("thesistitle_name");
		String sql="select thesistitle_id from thesistitle where thesistitle_name= '"+tn+"' ";
		new Thesistitle().set("thesistitle_submittime", date).set("thesistitle_selected", "B").set("thesistitle_name", tn).set("thesistitle_source", getPara("thesistitle_source")).set("thesistitle_type", getPara("thesistitle_type")).set("thesistitle_select_way", getPara("thesistitle_select_way")).save();
		int thesistitle_id=Db.queryInt(sql);//获取上面存的论文主键
		
		int tea_id=getSessionAttr("teacher_id");
		Record record=new Record().set("tch_rela_thesis_thesis",thesistitle_id).set("tch_rela_thesis_tch",tea_id);
		Db.save("teacher_rela_thesistitle", record);//存到教师论文关系表
		
		if(thesistitle_select_way.equals("B")){//B是盲选
			//new Dissertation().set("thesistitle_name", getPara("thesistitle_name")).set("dissType", getPara("dissType")).set("dissSrc",getPara("dissSrc")).set("thesistitle_select_way", getPara("thesistitle_select_way"))
			//.set("dissStateOfExamination", getPara("dissStateOfExamination")).set("dissSuitableForProfessional", getPara("dissSuitableForProfessional")).save();
			//String state=getPara("thesistitle_select_way");
//			new Thesistitle().set("thesistitle_submittime", date).set("thesistitle_selected", "B").set("thesistitle_name", tn).set("thesistitle_source", getPara("thesistitle_source")).set("thesistitle_type", getPara("thesistitle_type")).set("thesistitle_select_way", getPara("thesistitle_select_way")).set("thesistitle_checkstate", "F").save();
			//通过名字和提交时间查找论文主键
			Thesistitle T=new Thesistitle().set("thesistitle_selected", "B").set("thesistitle_id", thesistitle_id).set("thesistitle_checkstate", "A");
			T.update();
		
			//			Thesistitle tt=getModel(Thesistitle.class, "t");
//			tt.save();
		}
		else if(thesistitle_select_way.equals("C")){
			System.out.println("TTTT测试");
			Thesistitle T=new Thesistitle().set("thesistitle_selected", "A").set("thesistitle_id", thesistitle_id).set("thesistitle_checkstate", "A");
			T.update();
		String sqlstuId ="SELECT stu_rela_thesis_stu FROM `student_rela_thesistitle` where stu_rela_thesis_stu="+stuId+"";
		Integer stuIdExist=Db.queryInt(sqlstuId);//查找需要添加的学生主键是否已经有论文
		System.out.println("stuIdExist是 "+stuIdExist);
		if(stuIdExist==null){//该学生虚拟主键没有论文
			System.out.println("学生虚拟主键没有论文");
			//学号不存在，论文表增加一条记录
			Record record1=new Record().set("stu_rela_thesis_thesis",thesistitle_id).set("stu_rela_thesis_stu",stuId);
			Db.save("student_rela_thesistitle", record1);}//学生虚拟主键不存在，学生论文表增加一条新记录
		
		}
		else{
			renderJson("{\"success\":flase}");
		}
		renderJson("{\"success\":true}");
		//renderJson("success");
	}
	@ActionKey("/confirm")//未审核论文
	public void confirm(){
		Integer page = getParaToInt("page");
		Integer rows = getParaToInt("rows");
		int teacher_id=getSessionAttr("teacher_id");
		//未审核论文
		//String sql="from thesistitle as t left join student_rela_thesistitle as srt  ON t.thesistitle_id=srt.stu_rela_thesis_thesis left join student as s  ON srt.stu_rela_thesis_stu = s.student_id where t.thesistitle_checkstate = 'F' or t.thesistitle_checkstate = 'A' AND (t.thesistitle_select_way='C'or t.thesistitle_select_way='A') order by t.thesistitle_id desc";
		//String sql="from tea_stu_the where teacher_id="+teacher_id+" and (thesistitle_checkstate = 'A' or thesistitle_checkstate = 'B')";
		String sql="from tea_stu_the as t LEFT JOIN thesistitle on t.thesistitle_id =thesistitle.thesistitle_id where teacher_id="+teacher_id+" and ( t.thesistitle_checkstate = 'A' or t.thesistitle_checkstate = 'B')";
		Page<Thesistitle> thesistitlePages=Thesistitle.dao.paginate(page,rows, "select t.*", sql);
    	setAttr("confirm",thesistitlePages.getList() ); 
    	Map<String, Object> m = new HashMap<String, Object>();
		m.put("total", thesistitlePages.getTotalRow());
		m.put("rows", thesistitlePages.getList());
		renderJson(m);
	}
	@ActionKey("/confirmed")//已审核论文
	public void confirmed(){
		Integer page = getParaToInt("page");
		Integer rows = getParaToInt("rows");
		int teacher_id=getSessionAttr("teacher_id");
		//已审核论文
		//String sql="from thesistitle as t left join student_rela_thesistitle as srt  ON t.thesistitle_id=srt.stu_rela_thesis_thesis left join student as s  ON srt.stu_rela_thesis_stu = s.student_id where t.thesistitle_checkstate = 'D'or t.thesistitle_checkstate = 'C' order by t.thesistitle_id desc";
		//String sql="from tea_stu_the where teacher_id="+teacher_id+" and ( thesistitle_checkstate = 'C' or thesistitle_checkstate = 'D')";
		String sql="from tea_stu_the where teacher_id="+teacher_id+" and ( thesistitle_checkstate != 'A')";

		Page<Thesistitle> thesistitlePages=Thesistitle.dao.paginate(page,rows, "select tea_stu_the.*", sql);
    	setAttr("confirm",thesistitlePages.getList() ); 
    	Map<String, Object> m = new HashMap<String, Object>();
		m.put("total", thesistitlePages.getTotalRow());
		m.put("rows", thesistitlePages.getList());
		renderJson(m);
	}
	@ActionKey("/updated")//修改课题updated
	public void updated(){
		String stuId="";//获取学生虚拟主键
		if(getPara("Sin").length()>0){
			stuId=getPara("Sin");
			System.out.println("学生id1是"+stuId);
		}
		if(getPara("student_id").length()>0){
			stuId=getPara("student_id");
		}
		String thesistitle_select_way=getPara("thesistitle_select_way");//选题方式
		if(thesistitle_select_way.equals("盲选")||thesistitle_select_way.equals("B")){
			Record record=new Record().set("thesistitle_name", getPara("thesistitle_name")).set("thesistitle_id", getPara("thesistitle_id")).set("thesistitle_select_way", "B").set("thesistitle_type", getPara("thesistitle_type")).set("thesistitle_selected", "B").set("thesistitle_checkstate", "A").set("thesistitle_source", getPara("thesistitle_source"));
			Db.update("thesistitle", "thesistitle_id", record);
			Db.deleteById("student_rela_thesistitle", "stu_rela_thesis_stu", stuId);//由指定学生改成盲选时，需要删除学生论文表里面学生和论文的关系
		}
		else{
			String sqlstuId ="SELECT stu_rela_thesis_stu FROM `student_rela_thesistitle` where stu_rela_thesis_stu="+stuId+"";
			Integer stuIdExist=Db.queryInt(sqlstuId);//查找需要添加的学生学号是否已经有论文
			if(stuIdExist==null){//该学生虚拟主键没有论文
				System.out.println("学生没有论文");
				Record r=Db.findById("thesistitle", "thesistitle_id", getParaToInt("thesistitle_id")).set("thesistitle_select_way", "C").set("thesistitle_selected","A").set("thesistitle_type", getPara("thesistitle_type")).set("thesistitle_name", getPara("thesistitle_name")).set("thesistitle_source", getPara("thesistitle_source"));
				Db.update("thesistitle","thesistitle_id",r);
				Record record=new Record().set("stu_rela_thesis_thesis",getPara("thesistitle_id")).set("stu_rela_thesis_stu",stuId);
				Db.save("student_rela_thesistitle", record);//学生论文表中，把学生和论文关联起来
			}
			else{
				System.out.println("学生已经有了论文");
				int thesistitle_id=getParaToInt("thesistitle_id");
				new Thesistitle().findById(thesistitle_id).set("thesistitle_selected", "A").set("thesistitle_name", getPara("thesistitle_name")).set("thesistitle_source", getPara("thesistitle_source")).set("thesistitle_type", getPara("thesistitle_type")).set("thesistitle_select_way", getPara("thesistitle_select_way")).set("thesistitle_checkstate",getPara("thesistitle_checkstate") ).update();
			//通过论文Id更新论文表已存在的信息
				String studissupdate="update `student_rela_thesistitle` SET stu_rela_thesis_thesis="+thesistitle_id+" where stu_rela_thesis_stu="+stuId+"";
				Db.update(studissupdate);//学生主键存在，学生论文表只更新论文
		}
		}
		renderJson("{\"success\":true}");
	}
	//通过论文
	@ActionKey("/pass")
	public void pass(){
		System.out.println("通过的论文的id是"+getPara("thesistitle_id"));
		//获取id，找到要修改的记录
		int disId=getParaToInt("thesistitle_id");
		Record dis = Db.findById("thesistitle","thesistitle_id",disId).set("thesistitle_checkstate", "C");
		//修改dissStateOfExamination字段
		Db.update("thesistitle","thesistitle_id",dis);
		String sql="select stu_rela_thesis_id from student_rela_thesistitle where stu_rela_thesis_thesis= '"+disId+"' ";
		int rela_id=Db.queryInt(sql);//获取上面存的关系表id
		Record record=new Record().set("fthesis_student",rela_id);
		Db.save("finalthesis", record);//把学生论文关系id插到终稿
		
		Record record2=new Record().set("kickoff_student",rela_id);
		Db.save("kickoffreport", record2);//把学生论文关系id插到开题报告
		
		Record record3=new Record().set("initdraft_student",rela_id);
		Db.save("thesisinitdraft", record3);//把学生论文关系id插到初稿
		
		Record record4=new Record().set("thesistemp_student",rela_id);
		Db.save("thesismodifytemp", record4);//把学生论文关系id插到临时表
		renderJson("{\"success\":true}");
	}
	//不通过论文
	@ActionKey("/dispassview")
	public void dispassview(){
		//获取id，找到要修改的记录
		String thesistitle_id=getPara("id");
		System.out.println("测试不通过的论文的id是"+thesistitle_id);
		setAttr("ti",thesistitle_id);
		render("/pages1/dispass.jsp");
//		Record dis = Db.findById("thesistitle","thesistitle_id",disId).set("thesistitle_checkstate", "B");
//		//修改dissStateOfExamination字段
//		Db.update("thesistitle","thesistitle_id",dis);
//		renderJson("{\"success\":true}");
	}
	@ActionKey("/dispass")
	public void dispass(){
		int id=getParaToInt("thesistitle_id");//论文主键
		String thesistitle_tchmemo=getPara("thesistitle_tchmemo");//论文主键=getParaToInt("thesistitle_id");//论文主键
		Record r = Db.findById("thesistitle","thesistitle_id",id).set("thesistitle_checkstate", "B").set("thesistitle_tchmemo",thesistitle_tchmemo);
		Db.update("thesistitle","thesistitle_id",r);
		render("/pages1/finalT2.jsp");
	}
	//修改老师提交的课题
	public void edit(){
		System.out.println("不通过的论文的id是"+getParaToInt());
		//获取id，找到要修改的记录
//		Dissertation dis = Dissertation.dao.findById(getParaToInt());
		setAttr("thesistitle", Thesistitle.dao.findById(getParaToInt()));
		//修改dissStateOfExamination字段
//		dis.set("dissStateOfExamination", "不通过").update();
		
		Page<Thesistitle> thesistitle=Thesistitle.dao.paginate(1, 20, "select *", "from thesistitle where dissStateOfExamination='待审核' order  by id desc");
    	setAttr("confirm",thesistitle.getList() ); 
    	
    	//已审核论文
    	Page<Thesistitle> confirmed=Thesistitle.dao.paginate(1, 20, "select *", "from thesistitle where dissStateOfExamination='已审核' order  by id desc");
    	setAttr("confirmed",confirmed.getList() );  
    	
    	render("/pages1/dissertation_edit.jsp");	
	}
	//中期检查显示数据
	public void midcheck(){
		//从论文表，学生表，学生论文表里面取出数据
		String sql="from thesistitle as t left student_rela_thesistitle as srt  ON t.thesistitle_id=srt.stu_rela_thesis_thesis left join student as s  ON srt.stu_rela_thesis_stu = s.student_id order by t.thesistitle_id desc";
	  //String sql="from thesistitle as d left join student_rela_thesistitle as sd  ON d.id=sd.SDDissertationId left join student as st  ON sd.SDStudentId = st.id order by d.id desc";
		Page<Thesistitle> thesistitlePages=Thesistitle.dao.paginate(1, 20, "select d.*,sd.SDStudentId,st.StudentName,st.StudentId ", sql);
		setSessionAttr("dissertationList",thesistitlePages.getList() ); 
//		String stunumber = getSessionAttr("userNum");
		System.out.println("数据是"+thesistitlePages.getList().toString());
		if(getPara("stuId") != null && getPara("stuId").length() >= 0){
			String stuId=getPara("stuId");//获取学生虚拟主键
			String sqlstuId ="SELECT stuId FROM `midcheck_table` where stuId="+stuId+"";
			String stuIdExist=Db.queryStr(sqlstuId);
			if(stuIdExist==null){//学生虚拟主键为空，增加一条记录
				System.out.println("增加一条记录"+"stuIdExist是"+stuIdExist);
				Record record=new Record().set("gongZuoLiang",getPara("gongZuoLiang")).
						set("stuId",getPara("stuId")).
						set("tiMuNanDu",getPara("tiMuNanDu")).
						set("sheJiZhiShi",getPara("sheJiZhiShi")).set("stuTaiDu",getPara("stuTaiDu")).
						set("record",getPara("record")).
						set("mission",getPara("mission")).set("jinDu",getPara("jinDu")).
						set("zhiDaoTime",getPara("zhiDaoTime")).set("other",getPara("other")).set("cuoShi",getPara("cuoShi"));
			Db.save("midcheck_table", record);
			}
			else {
				System.out.println("更新一条记录"+"stuIdExist是"+stuIdExist);
				String update="update `midcheck_table` SET tiMuNanDu='"+getPara("tiMuNanDu")+"',sheJiZhiShi='"+getPara("sheJiZhiShi")+"' ,stuTaiDu='"+getPara("stuTaiDu")+"' ,record='"+getPara("record")+"' ,gongZuoLiang='"+getPara("gongZuoLiang")+"'where stuId="+stuId+"";
				Db.update(update);
			}
		}
		
		System.out.println("this is midcheck");
		render("/pages1/flowManageTeacher_6.jsp");
		
	}
	//中期检查保存教师意见
	@ActionKey("/midsave")
	public void midcheckSave(){
//			String medium_workload=getPara("medium_workload");
//			String medium_measure=getPara("medium_measure");
//			String medium_othercontent=getPara("medium_othercontent");
//			String medium_workload=getPara("medium_workload");
//			String medium_workload=getPara("medium_workload");
//			String medium_workload=getPara("medium_workload");
//			String medium_workload=getPara("medium_workload");
//			String medium_workload=getPara("medium_workload");
	}
	//编辑审核意见
	public void editShyj(){
//	String StudentId=getPara("StudentId");
//	String sql="SELECT * from student WHERE StudentId="+StudentId+"";
	String id=getPara("id");
	String sql="SELECT * from student WHERE id="+id+"";
	Record record =Db.findFirst(sql);
	setSessionAttr("stu", record);
	getSession().setAttribute("stu", record);
	System.out.println(record.toString());
	renderJson("{\"success\":true}");

}
	public void dissDraft(){
		//获取论文表,学生表数据sql语句
		//String sql="from thesistitle as d left join student_rela_thesistitle as sd  ON d.id=sd.SDDissertationId left join student as st  ON sd.SDStudentId = st.id order by d.id desc";
		String sql="from thesistitle as t left student_rela_thesistitle as srt  ON t.thesistitle_id=srt.stu_rela_thesis_thesis left join student as s  ON srt.stu_rela_thesis_stu = s.student_id order by t.thesistitle_id desc";
		Page<Thesistitle> thesistitlePages=Thesistitle.dao.paginate(1, 20, "select d.*,sd.SDStudentId,st.StudentId,st.StudentName ", sql);
		setSessionAttr("dissertationList",thesistitlePages.getList() );
		render("/pages1/flowManageTeacher_8.jsp");		
	}
	//论文草稿意见和草稿附件上传
	public void dissDraftOpinion(){
//		UploadFile uf=getFile();
//		String  path=uf.getSaveDirectory()+uf.getFileName();//取出草稿url
		String dissId=getPara("DDdissId");
		String sql="select DDdissId from dissertation_draft where DDdissId="+dissId+" ";
		if(Db.findFirst(sql) != null){//如果论文草稿已经存在，就修改
			String update="update `dissertation_draft` SET DDdissShortComment='"+getPara("DDdissShortComment")+"'where DDdissId="+dissId+"";
			Db.update(update);
		}
		else{//论文草稿不存在就增加
		Record record=new Record().set("DDdissId",getPara("DDdissId")).set("DDdissShortComment",getPara("DDdissShortComment")).set("DDDraftURL",getPara("DDDraftURL"));
		Db.save("dissertation_draft", record);
		}
		redirect("/dissertationtea/dissDraft");
	}

	

}
